package src.com.zaizai123;
import java.awt.*;

public class LayoutPracticeByGPT {

        public static void main(String[] args) {
            Frame frame = new Frame("复杂布局示例");

            // 设置主容器的布局为 BorderLayout
            frame.setLayout(new BorderLayout());

            // 顶部区域 - 使用 FlowLayout 或嵌套的 GridLayout
            Panel topPanel = new Panel(new FlowLayout(FlowLayout.CENTER));
            topPanel.add(new Button("Button"));
            frame.add(topPanel, BorderLayout.NORTH);

            // 底部区域 - 使用 FlowLayout 或嵌套的 GridLayout
            Panel bottomPanel = new Panel(new FlowLayout(FlowLayout.CENTER));
            bottomPanel.add(new Button("Button"));
            frame.add(bottomPanel, BorderLayout.SOUTH);

            // 左侧区域 - 使用 3x1 的 GridLayout
            Panel leftPanel = new Panel(new GridLayout(3, 1));
            leftPanel.add(new Button("Button"));
            leftPanel.add(new Button("Button"));
            leftPanel.add(new Button("Button"));
            frame.add(leftPanel, BorderLayout.WEST);

            // 右侧区域 - 使用 3x1 的 GridLayout
            Panel rightPanel = new Panel(new GridLayout(3, 1));
            rightPanel.add(new Button("Button"));
            rightPanel.add(new Button("Button"));
            rightPanel.add(new Button("Button"));
            frame.add(rightPanel, BorderLayout.EAST);

            // 中间区域 - 使用 2x3 的 GridLayout
            Panel centerPanel = new Panel(new GridLayout(2, 3));
            centerPanel.add(new Button("Button"));
            centerPanel.add(new Button("Button"));
            centerPanel.add(new Button("Button"));
            centerPanel.add(new Button("Button"));
            centerPanel.add(new Button("Button"));
            frame.add(centerPanel, BorderLayout.CENTER);

            // 设置框架的大小和可见性
            frame.setSize(600, 400);
            frame.setVisible(true);
        }

}
